import socket

#实例化
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#绑定地址
server_socket.bind(("127.0.0.1", 8080))
#监听数
server_socket.listen(5)

print()

client_socket,address = server_socket.accept()
print(f"我们收到来自{address[0]}:{address[1]}的连接")
while True:
    data = client_socket.recv(1024)
    decoded_data = data.decode("utf-8")
    if not data:
        break
    elif data == "exit":
        break
    print(f"收到消息：{decoded_data}")
    client_socket.send(input("输入回复：").encode("utf8"))

client_socket.close()
